import { request } from '@umijs/max';

// 获取项目列表
export async function queryProjects(params?: any) {
  return request('/api/projects', {
    params
  });
}

// 获取项目详情
export async function queryProjectsDetial(project_id: string | null) {
  return request(`/api/projects/${project_id}`);
}



// 删除项目
export async function delProject({ id }: { id: string | number }) {
  return request(`/api/projects/${id}`, {
    method: 'DELETE',
  });
}

// 创建项目
export async function addProject(data: any) {
  return request(`/api/projects`, {
    method: 'POST',
    data,
    requestType: 'form',
  });
}

// 更新项目
export async function editProject(data: any) {
  return request(`/api/projects`, {
    method: 'POST',
    data,
    requestType: 'form',
  });
}

// 更新项目
export async function getProjectDetail(project_id: any) {
  return request(`/api/projects/${project_id}`, {
    method: 'get',
  });
}


// 上传项目剧本文件
export async function queryUploadProject(data: any) {
  const { project_id, ...rest } = data;
  return request(`/api/projects/${project_id}/scripts`, {
    method: 'PUT',
    data: rest
  });
}

// 获取剧本详情
export async function queryProjectFile(project_id: any) {
  return request(`/api/projects/scripts/${project_id}`);
}
